![]() ![]() |
Q: How do I turn on Macintosh screen menu bars in Mac OS X Aqua Swing applications? A: A Java application's Swing menu bar is by default located in the application's window. Defining the Java property com.apple.macos.useScreenMenuBar=true will force JMenuBars in the Aqua look and feel to appear as screen menu bars on Mac OS X if the application also uses "setJMenuBar" to associate it with the JFrame, and hasn't used "setMenuBar" to put a heavyweight java.awt.MenuBar on the JFrame. Otherwise it's just an ordinary Swing component which will appear in the window the way any other component would. If the application can also be run as an applet, like SwingSet2, you'll have to make it conditional as shown in Listing 1 because Applets can only have screen menu bars if they're in their own JFrame.
This property is by default set to true in the MRJApp.properties file in Project Builder Java application projects created from the project builder templates. The property can also be set in MRJAppBuilder for new applications, added to already packaged Java applications, or set programmatically before the first Aqua JMenuBar is created. To set the property in MRJAppBuilder for an application being built add it to the list of properties in the "Java Properties" panel. To set the property in an existing application it is necessary to add the property to the MRJApp.properties text file which is located in the applications package Contents/Resources/ folder. To open an applications package in the Finder Control-Click on the application to bring up the contextual menu, and select the menu item "Show Package Contents." The MRJApp.properties file can be edited with any standard text editor. [Jan 31 2001] |
||
Developer Documentation | Technical Notes | Development Kits | Sample Code |